<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name = "format-detection" content="telephone = no" />
<title>{$config_sitename}</title>
<meta name="description" content="">
<meta name="keywords" content="">
<link href="__CSS__/swiper-3.2.7.min.css?t={$ver}" rel="stylesheet" type="text/css">
<link href="__CSS__/common.css?t={$ver}" rel="stylesheet">
<link href="__CSS__/recipepp.css?t={$ver}" rel="stylesheet">
<link href="__CSS__/yf.css?t={$ver}" rel="stylesheet">
</head>
<body class="body-pad cl-b-lgrey">
	<div class="loading-wrapper">
		<div class="loading"></div>
	</div>
	<div class="ub ub-ac page-header">
		<a href="javascript:history.back();" class="clickable"><span class="icon-back"></span></a>
		<div class="ub-f1 page-name">{$detail.title}</div>
		<a href="{:U('Index/index')}" class="clickable "><span class="ub-pc icon-back-home"></span></a>
	</div>
	<div class="sp-vedio-wrapper clickable-deep" style="display: none;">观看视频</div>
	<div class="sp-detail-wrapper cl-b-white sp-wrapper-item">
		<div class="sp-detail-img" data-pic="{$detail.pic}">
			<img class="lazy rimg yf-pic-show" src="{$detail.image}" data-pic="{$detail.image}">
		</div>
		<div class="sp-detail-user ub ub-ver ub-pc ub-ac">
			<img src="{$userInfo.uavatar}" class="lazy tx-cir ava-js" data-url="{:U('Ucenter/index')}?id={$detail.userid}">
			<p class="cl-f-dgrey f14 ssp-detail-username ub ub-ac">{$userInfo.nickname}<eq name="userInfo.ifrz" value="1"><span class="icon-daren"></span></eq></p>
			<p class="cl-f-lgrey f12">发布时间：{$detail.create_time}</p>
		</div>
		<div class="sp-detail-intro f12 cl-f-grey">
			<p>{$detail.content}</p>
		</div>
		<div class="sp-zan-con ub ub-ac ub-pc">
			<div class="ub ub-ver ssp-detail-like dig-js" data-status="{$dig}">
			    <if condition="$dig eq 1">
    				<img src="__IMAGES__/icon-zan.png" class="ssp-blike">
    				<p class="f12 cl-f-lorange">{$detail.goodnum}</p>
				<else/>
				    <img src="__IMAGES__/sp-ic2.png" class="ssp-blike">
				    <p class="f12 cl-f-lorange" style="color: #333;">{$detail.goodnum}</p>
				</if>
			</div>
			<if condition="$detail.type eq 1">
			
			
			<div class="ub ub-ver sp-detail-like coll-js" data-status="{$coll}">
    			<if condition="$coll eq 1">
    				<img src="__IMAGES__/icon-star.png" class="ssp-blike">
    				<p class="f12 cl-f-lorange">{$detail.favoritenum}</p>
    			<else/>
    			    <img src="__IMAGES__/sp-ic3.png" class="ssp-blike">
    				<p class="f12 cl-f-lorange" style="color: #333;">{$detail.favoritenum}</p>
    			</if>
			</div>
			
			</if>
		</div>
	</div>
	<if condition="$detail.type eq 1">
	<div class="sp-yongliao-wrapper cl-b-white sp-wrapper-item">
		<h3 class="sp-title cl-f-dgrey">用料</h3>
		<foreach name="detail.works_materials" item="wm">
		<p class="yongliao-item ub ub-pj cl-f-grey"><span class="yongliao-l text-overflow">{$wm.mname}</span><span class="yongliao-r">{$wm.mvalue}</span></p>
		</foreach>
	</div>
	<div class="sp-step-wrapper cl-b-white sp-wrapper-item" data-pic="{$stepPic}">
		<h3 class="sp-title cl-f-dgrey">做法</h3>
		<foreach name="detail.works_makestep" item="ms">
		<div class="sp-step-info cl-f-grey"><span class="sp-step-num cl-f-orange">{$ms.num}.</span>{$ms.scontent}</div>
		<div class="sp-step-img yf-pic-show" data-pic="{$ms.simage}">
			<img src="{$ms.simage}" alt="" class="rimg">
		</div>
		</foreach>
	</div>
	<div class="sp-tips-wrapper cl-b-white sp-wrapper-item">
		<h3 class="sp-title cl-f-orange f14">小贴士</h3>
		<p class="cl-f-grey">{$detail.note}</p>
	</div>
	<!-- <div class="sp-learn-wrapper cl-b-white sp-wrapper-item">
		<h3 class="sp-title cl-f-dgrey f16">大家学做的<span class="comment-count-con">(<span class="comment-count">{$copyNum}</span>)</span></h3>
		<div class="sp-learn-list ub ub-ac">
		<foreach name="copyInfo" item="cp">
			<div class="sp-learn-item ub-f1">
				<div class="lazy" data-original="{$cp.image}">
					<img src="__IMAGES__/o8.png" class="oimg">
					<img src="{$cp.uavatar}" alt="" class="tx-cir sp-learn-tx">
				</div>
				<p class="cl-f-orange ub-con text-overflow">{$cp.nickname}</p>
				<p class="cl-f-grey ub-con">{$cp.content}</p>
			</div>
		</foreach>
		</div>
	</div> -->
    
    <div class="sp-learn-wrapper cl-b-white sp-wrapper-item">
        <h3 class="sp-title cl-f-dgrey f16">大家学做的<span class="comment-count-con">(<span class="comment-count">{$copyNum}</span>)</span></h3>
        <div class="sp-learn-list swiper-container">
            <div class="swiper-wrapper">
         <foreach name="copyInfo" item="cpp">
                <div class="swiper-slide ub ub-ac">
                    <foreach name="cpp" item="cp">
                        <div class="sp-learn-item ub ub-ver clickable  href-js" data-url="{:U('Work/detail')}?workid={$cp.workid}" >
                            <div class="lazy" data-original="{$cp.image}">
                                <img src="__IMAGES__/o8.png" class="oimg">
                                <img src="{$cp.uavatar}" alt="" class="tx-cir sp-learn-tx">
                            </div>
                            <p class="cl-f-orange  text-overflow">{$cp.nickname}</p>
                            <p class="cl-f-grey ">{$cp.content}</p>
                        </div>
                    </foreach>
                </div>
          </foreach>
            </div>
        </div>
       <!--  <div class="sp-learn-list ub ub-ac">
        </div> -->
    </div>
    </if>
    
	<ul class="sp-comment-wrapper comment-list-wrapper cl-b-white">
		<li class="sp-title cl-f-dgrey comment-list-title ub ub-pj ub-ae">
			<p class="f16">大家一起交流<span class="comment-count-con">(<span class="comment-count">{$detail.msgnum|getNullNum}</span>)</span></p>
			<p class="f14 href-js" data-url="{:U('Index/msgList')}?type={$type}&id={$detail.workid}">查看所有评论</p>
		</li>
		<foreach name="msglist" item="ml">
		<li class="ub comment-h1 clickable row" id="msg_{$ml.id}">
			<img src="{$ml.uavatar}" class="tx-cir lazy ava-js" data-url="{:U('Ucenter/index')}?id={$ml.userid}">
			<div class="comment-text ub-f1">
				<p class="cl-f-lorange comment-user href-js" data-user="{$ml.nickname}" data-id="{$ml.id}" data-uid="{$ml.userid}" data-url="{:U('Index/msgList')}?type={$type}&id={$detail.workid}&msgid={$ml.id}">{$ml.nickname}</p>
				<p class="cl-f-lgrey comment-time href-js" data-user="{$ml.nickname}" data-id="{$ml.id}" data-uid="{$ml.userid}" data-url="{:U('Index/msgList')}?type={$type}&id={$detail.workid}&msgid={$ml.id}" >{$ml.create_time|format_time}</p>
				<div class="cl-f-grey comment-content">
					<p class="href-js" data-user="{$ml.nickname}" data-id="{$ml.id}" data-uid="{$ml.userid}" data-url="{:U('Index/msgList')}?type={$type}&id={$detail.workid}&msgid={$ml.id}" >{$ml.content}</p>
    				<foreach name="ml.childlist" item="cl">
    					<div class="comment-h2 clickable" id="msg_{$cl.id}">
    						<span class="cl-f-lorange comment-user href-js" data-user="{$cl.nickname}" data-id="{$cl.id}" data-uid="{$cl.userid}" data-url="{:U('Index/msgList')}?type={$type}&id={$detail.workid}&msgid={$cl.id}">@{$cl.touser.nickname}</span>{$cl.content}
    					</div>
    				</foreach>
				</div>
			</div>
		</li>
		</foreach>
	</ul>
	<form class="row ub five-grid sp-five-grid f12 cl-b-white cl-f-dgrey ub-pj">
    	<div class="ub-ver clickable ub-pc href-js" data-url="{:U('Index/msgList')}?type={$type}&id={$detail.workid}"><img src="__IMAGES__/sp-ic1.png"><p>评论</p></div>
    	<div class="ub-ver clickable ub-pc dig-js" data-status="{$dig}">
    	    <if condition="$dig eq 1">
    	       <img src="__IMAGES__/icon-zan.png"><p style="color: #ff6633;">点赞</p>
    	    <else/>
    	       <img src="__IMAGES__/sp-ic2.png"><p>点赞</p>
    	    </if>
	    </div>
    	<label class="ub-f1 sp-pai clickable-deep ub ub-pc ub-ac cl-b-orange cl-f-white href-js" for="sp-upload" data-url="{:U('Work/add')}">
    		<span><img src="__IMAGES__/sp-ic5.png"></span>
    		<span>上传作品</span>
    	</label>
    	<div class="ub-ver clickable ub-pc coll-js" data-status="{$coll}">
    	    <if condition="$coll eq 1">
    	       <img src="__IMAGES__/icon-star.png"><p style="color: #ff6633;">收藏</p>
    	    <else/>
    	       <img src="__IMAGES__/sp-ic3.png"><p>收藏</p>
    	    </if>
	    </div>
    	<if condition="$is_del eq 0">
    	<div class="ub-ver clickable ub-pc fans-js" data-status="{$fans}">
    	   <if condition="$fans eq 1">
        	   <img src="__IMAGES__/sp-ic4-o.png"><p style="color: #ff6633;">关注</p>
	       <else/>
	           <img src="__IMAGES__/sp-ic4.png"><p>关注</p>
    	   </if>
	   </div>
    	<else/>
    	<div class="ub-ver clickable ub-pc del-js"><img src="__IMAGES__/sp-ic6.png"><p>删除</p></div>
    	</if>
    </form>
	<script src="__JS__/jquery-1.11.1.min.js?t={$ver}"></script>
	<script src="__JS__/jquery.lazyload.min.js?t={$ver}"></script>
    <script src="__JS__/swiper-3.2.7.jquery.min.js?t={$ver}"></script>
	<script src="__JS__/custom.js?t={$ver}"></script>
	<script src="__JS__/common.js?t={$ver}"></script>
	<script>
    var img_url = "__IMAGES__";
    $(function(){
        var mySwiper = new Swiper ('.swiper-container', {
        }); 
    	var userid = "{$userid}";
        $('.href-js').click(function(e){
            e.preventDefault();
            var url = $(this).attr('data-url');
            if(url == undefined || url == '')
            {
                showToast('参数错误');
                return false;
            }
            location.href = url;
        });

        $('.ava-js').click(function(e){
            e.preventDefault();
            e.stopPropagation();
            var url = $(this).attr('data-url');
            location.href = url;
        });

        $('.fans-js').click(function(e){
            e.preventDefault();
            var userid = "{$userid}";
            if(userid == undefined || userid == 0 || userid == '')
            {
                showToast('请先登录');
                setTimeout(function(){
                    location.href = "{:U('Login/index')}";
                }, 1000);
                return false;
            }
            var _this = $(this);
            var status = _this.attr('data-status');
            var userid = "{$detail.userid}";
            var path = 'addfans';
            if(status == 1)
            {
                path = 'cancelfans';
            }

            $.ajax({
			    url: '/weixin/index/' + path,
			    type: 'GET',
			    dataType: 'json',
			    data: {
				    userid: userid
			    },
			    success: function(res)
			    {
				    if(res.status == 1)
				    {
				    	if(status == 1)
				    	{
					    	_this.find('img').attr('src' , '__IMAGES__/sp-ic4.png');
					    	_this.find('p').css('color', '#333');
					    	_this.attr('data-status', 0);
				    	}
				    	else
				    	{
				    		_this.find('img').attr('src' , '__IMAGES__/sp-ic4-o.png');
				    		_this.find('p').css('color', '#ff6633');
				    		_this.attr('data-status', 1);
				    	}
				    }
				    else
				    {
					    showToast(res.info);
					    setTimeout(function(){
	                        if(res.url)
	                        {
                        	   location.href = res.url;
	                        }
                        }, 1000);
				    }
			    },
			    error: function(res)
			    {
				    showToast('系统繁忙');
			    }
			});
        });

        $('.coll-js').click(function(e){
            e.preventDefault();
            if(userid == undefined || userid == 0 || userid == '')
            {
                showToast('请先登录');
                setTimeout(function(){
                    location.href = "{:U('Login/index')}";
                }, 1000);
                return false;
            }

            if(userid == "{$detail.userid}")
            {
            	showToast('你不能收藏自己的作品!');
                return false;
            }
            
            var _this = $(this);
            var status = _this.attr('data-status');
            var path = 'addfavorite';
            if(status == 1)
            {
                path = 'cancelfavorite';
            }

            var num = $('.coll-js .cl-f-lorange').text();
            if(status == 1)
            {
            	$('.coll-js').find('img').attr('src', '__IMAGES__/sp-ic3.png');
            	$('.coll-js').find('p').css('color', '#333');
                $('.coll-js').attr('data-status', 0);
                $('.coll-js .cl-f-lorange').text(parseInt(num) - 1);
            }
            else
            {
            	$('.coll-js').find('img').attr('src', '__IMAGES__/icon-star.png');
                $('.coll-js').find('p').css('color', '#ff6633');
            	$('.coll-js').attr('data-status', 1);
            	$('.coll-js .cl-f-lorange').text(parseInt(num) + 1);
            }
            
            $.ajax({
                url: '/weixin/index/' + path,
                type: 'GET',
                dataType: 'json',
                data: {
                	infoid: "{$detail.workid}"
                },
                success: function(res){
                    if(res.status == 1)
                    {
//                         var num = $('.coll-js .cl-f-lorange').text();
//                         if(status == 1)
//                         {
//                         	$('.coll-js').find('img').attr('src', '__IMAGES__/sp-ic3.png');
//                         	$('.coll-js').find('p').css('color', '#333');
//                             $('.coll-js').attr('data-status', 0);
//                             $('.coll-js .cl-f-lorange').text(parseInt(num) - 1);
//                         }
//                         else
//                         {
//                         	$('.coll-js').find('img').attr('src', '__IMAGES__/icon-star.png');
//                             $('.coll-js').find('p').css('color', '#ff6633');
//                         	$('.coll-js').attr('data-status', 1);
//                         	$('.coll-js .cl-f-lorange').text(parseInt(num) + 1);
//                         }
                    }
                    else
                    {
                        showToast(res.info);
                        setTimeout(function(){
	                        if(res.url)
	                        {
                        	   location.href = res.url;
	                        }
                        }, 1000);
                    }
                },
                error: function(res){
                    showToast('系统繁忙');
                }
            });
        });

        $('.dig-js').click(function(e){
            e.preventDefault();
            if(userid == undefined || userid == 0 || userid == '')
            {
                showToast('请先登录');
                setTimeout(function(){
                    if(res.url)
                    {
                	   location.href = "{:U('Login/index')}";
                    }
                }, 1000);
                return false;
            }
            var _this = $(this);
            var status = _this.attr('data-status');
            var path = 'adddig';
            if(status == 1)
            {
                path = 'canceldig';
            }
            $.ajax({
                url: '/weixin/index/' + path,
                type: 'GET',
                dataType: 'json',
                data: {
                    digtype: 1,
                    infoid: "{$detail.workid}"
                },
                success: function(res){
                    if(res.status == 1)
                    {
                    	var num = $('.dig-js .cl-f-lorange').text();
                        if(status == 1)
                        {
                        	$('.dig-js').find('img').attr('src', '__IMAGES__/sp-ic2.png');
                        	$('.dig-js').find('p').css('color', '#333');
                            $('.dig-js').attr('data-status', 0);
                            $('.dig-js .cl-f-lorange').text(parseInt(num) - 1);
                        }
                        else
                        {
                        	$('.dig-js').find('img').attr('src', '__IMAGES__/icon-zan.png');
                        	$('.dig-js').find('p').css('color', '#ff6633');
                            $('.dig-js').attr('data-status', 1);
                            $('.dig-js .cl-f-lorange').text(parseInt(num) + 1);
                        }
                    }
                    else
                    {
                        showToast(res.info);
                        setTimeout(function(){
	                        if(res.url)
	                        {
	                        	location.href = res.url;
	                        }
                        }, 1000);
                    }
                },
                error: function(res){
                    showToast('系统繁忙');
                }
            });
        });

        $('.del-js').click(function(e){
            e.preventDefault();
            var workid = "{$detail.workid}";
            $.ajax({
                url: '/weixin/work/delworks',
                type: 'GET',
                dataType: 'json',
                data: {
                    workid: workid
                },
                success: function(res){
                    showToast(res.info);
                    if(res.status == 1)
                    {
                        setTimeout(function(){
                            location.href = res.url;
                        }, 2000);
                    }
                },
                error: function(res){
                    showToast('系统繁忙');
                }
            });
        });
    });
	</script>
	<script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
    <script>
		var shareTitle = "{$share.shareTitle}";
		var shareDesc = "{$share.shareDesc}";
		var shareUrl = "{$share.shareUrl}";
		var shareImg = "{$share.sharePic}";
		var jsdk = {$jsdk};
	</script>
	<script src="__JS__/wx.js?t={$ver}"></script>
</body>
</html>